//
//  ViewController.m
//  SLPagerView
//
//  Created by l.t.zero on 2022/1/7.
//

#import "ViewController.h"
#import "SLPagerView.h"
#import "SLPagerLocker.h"
#import "InfinitePagerViewController.h"
#import "FrontViewController.h"
#import "SnapToCenterViewController.h"
#import <objc/runtime.h>

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation ViewController{
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

}

- (void)viewWillLayoutSubviews{
    [super viewWillLayoutSubviews];
    self.tableView.frame = self.view.bounds;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0);
    _tableView.tableFooterView = [[UIView alloc] init];
    _tableView.estimatedRowHeight = 50;
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"123"];
    [self.view addSubview:_tableView];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"123" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    switch (indexPath.row) {
        case 0:
            cell.textLabel.text = @"loop";
            break;
        case 1:
            cell.textLabel.text = @"header & footer";
            break;
            
        default:
            cell.textLabel.text = @"page centered";
            break;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0){
        InfinitePagerViewController *pvc = [InfinitePagerViewController new];
        [self presentViewController:pvc animated:YES completion:nil];
    }else if (indexPath.row == 1){
        FrontViewController *pvc = [FrontViewController new];
        [self presentViewController:pvc animated:YES completion:nil];
    }else{
        SnapToCenterViewController *pvc = [SnapToCenterViewController new];
        [self presentViewController:pvc animated:YES completion:nil];
    }
}

@end
